define(function(require, exports, module){
    var toUrl = require('m/iyue12/js/tourl');
    var objData = [
        
    ]
    var P = {
        _container:$('#content'),
        _init(){
            P.bind();
            seajs.use(['ui/1.0.0/lazyload/lazyload'],function(){
                $('.mz_list').lazyload({
                    type:'fn',
                    source:$('.mz_list'),
                    onchange:function(){
                       P.render(objData);
                    }
                });
            })
        },
        bind(){
            var me = P._container;
            me.find('[data-op]').off('click');
            me.off('click','[data-op]').on('click', '[data-op]', function(event){
                var _this = $(this);
                var op = $(this).data('op');
                P[op](_this,event);
            });
        },
        render(data){
            var oUl = P._container.find('.mz_list');
            var iHtml = "";
            for(var i=0,len=data.length;i<len;i++){
                iHtml+=`<li data-id="${data[i]._id}" data-video="${location.protocol+data[i].video}" data-uid="${data[i].uid}" data-serveid="${data[i].serveId}">
                    <div class="vid" data-op="videoOpen">
    					<img src="${data[i].cover}" alt="${data[i].name}">
    					<a href="javascript:;"></a>
    				</div>
    				<div class="yueta cur">
    					<div class="yueta_hd">
    						<div class="img" data-op="user">
    							<img src="${data[i].photo}" alt="${data[i].name}">
    						</div>
    						<div class="cont">
    							<h4>${data[i].name}</h4>
    							<p>${data[i].city}</p>
    						</div>
    					</div>
    					<div class="yueta_ft" data-op="yueTa">
    						<a href="javascript:;">
    							<span>约Ta</span>
    						</a>
    					</div>
    				</div>
    			</li>`
            }
            P._container.find('.loading').hide();
            oUl.html(iHtml);
        },
        yueTa(obj){
            var oPar = obj.parents('li');
            var data = {
                "type":"23",
                "category_id":oPar.data('serveid')+'',
                "user_id":oPar.data('uid')+''
            };
            toUrl.init(data);
        },
        userAgent(){
            if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
                return true;
            } else if (/(Android)/i.test(navigator.userAgent)) {
                return false;
            } else {
                return false;
            }
        },
        videoOpen(obj){
            var oPar = obj.parents('li');
            var videoUrl = oPar.data('video')+'';
            if(P.userAgent()){
                var videoObj = {
            		play_video:videoUrl
            	};
            	var str =  JSON.stringify(videoObj);
            	document.location = "yuecom?"+str;
            }else {
                var videoObj = {
            		url:videoUrl
            	};
            	var str =  JSON.stringify(videoObj);
                window.myjs.doAction("play_video",str);
            }
        },
        //用户头像
        user:function(obj){
            var oPar = obj.parents('li');
            var data = {
                "type":"14",
                "user_id":oPar.data('uid')+''
            };
            toUrl.init(data);
        }
    }

    module.exports = {
        init:P._init
    }
})
